function Ajax()
{
    this.request = false;
    this.xmlHttp = null;
    this.timeOut = 10000;
    this.statusObj = null;
    this.statusCode = null;
    this.ctf = false;
    this.AjaxObj = function()
    {
        if(window.XMLHttpRequest) {
            this.request = new XMLHttpRequest();
            if(this.request.overrideMimeType) {
                this.request.overrideMimeType('text/html; charset=utf-8');
            }
        }else if(window.ActiveXObject) {
            var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
            for(var i=0; i<versions.length; i++) {
                try {
                    this.request = new ActiveXObject(versions[i]);
                    if(request) {
                        return this.request;
                    }
                } catch(e) {}
            }
        }
        return this.request;
    }
    this.exception = function(code){
        alert('error code:'+code+' try the next request after '+PINGTIME/1000+' s');
        PINGTIME = PINGTIME+PINGTIME;
    }
    this.callServer = function (method,url,call,data,wait) {
        var xmlHttp = this.AjaxObj();
        var self = this;
        if(!xmlHttp)
        {
            alert('You Browser cannot run ajax');
            return;
        }
        url += (url.indexOf("?")>-1 ? "&" : "?") + "rnd="+this.rnd();
        xmlHttp.open(method, url, wait);
        this.start();
        if(method == "POST") xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        xmlHttp.send(data);
        function ReAbort(){this.ctf=true;xmlHttp.abort();}
        setTimeout(ReAbort,this.timeOut);
        xmlHttp.onreadystatechange = function(){
            if(this.ctf){
                this.ontimeout();return;
            }
            if(xmlHttp.readyState == 4) {
                this.statusCode=xmlHttp.status;
                //try{ clearTimeout(ct); } catch(e) {};
                try{
                    if(this.statusCode == 200){
                        PINGTIME == 5000 ?false:PINGTIME = 5000;
                        if(isset(call)) {
                            call(xmlHttp.responseText);
                        }
                    }else{
                        return self.exception(this.statusCode);
                    }
                }catch(e){return this.exception();}
               this.end();
            }       
        }
        this.xmlHttp = xmlHttp;
    }
    this.rnd = function(){return ((new Date) *1);}
    this.getCall = function(mod,call)
    {
        this.callServer('GET',URL+mod,call,null,5000);
    }
    this.postCall= function(mod,call,data)
    {
        var postdata = ''; 
        for(name in data)
        {
           postdata += name+'='+escape(data[name])+'&';
        }
        this.callServer("POST",URL+mod,call,postdata,10000);
    }
    this.start = function()
    {
        //this.statusObj = createAjaxStartObj();
    }
    this.end = function(){alert('request end');}
    this.ontimeout = function(){alert('time out');}
}

